﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LibrarySync2.Common.Interfaces;

namespace LibrarySync2.ChildForms
{
    public class MediaFileFormListItem : IFormListItem, IComparable
    {
        protected const long OneMeg = 1048576;

        #region IFormListItem Members

        public bool IsSelected { get; set; }

        public IMediaFile MediaFile { get; protected set; }

        public string Name { get { return MediaFile.Name; } }

        public string UniqueId { get { return MediaFile.Id; } }

        public long Size { get { return MediaFile.FileSize / OneMeg; } }

        #endregion

        public MediaFileFormListItem(bool isSelected, IMediaFile mediaFile)
        {
            IsSelected = isSelected;
            MediaFile = mediaFile;
        }

        #region IComparable Members

        public int CompareTo(object obj)
        {
            var listItem = obj as IFormListItem;
            if (listItem == null)
                return 1;

            return this.Name.CompareTo(listItem.Name);
        }

        #endregion
    }
}
